home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Games of Daze
/
Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso
/
x2ftp
/
msdos
/
convert
/
c2snd201
/
conv2snd.doc
< prev
next >
Wrap
Text File
|
1994-09-11
|
23KB
|
483 lines
(******CONV2SND.DOC******)
* *
* CONV2SND.PAS: 2.00 *
* *
* February 3, 1993 *
* Kenneth Udut *
* Revised 6/22/94 *
* J.L. Hayes *
* *
(******CONV2SND.DOC******)
CONV2SND.EXE, CONV2SND.PAS, CONV2SND.DOC, CONV2SND.HST HEREBY ARE
RELEASED INTO THE PUBLIC DOMAIN. UNLESS SPECIAL CIRCUMSTANCES WARRANT
OTHERWISE, EVERY SOFTWARE PRODUCT CREATED BY (_KENNETH UDUT_) WILL:
1. BE RELEASED INTO THE PUBLIC DOMAIN, FREELY COPYABLE AND CHANGEABLE.
2. INCLUDE THE SOURCE CODE.
AS THE AUTHOR OF (_CONV2SND_), I WOULDN'T MIND CREDIT FOR MY WORK.
HOWEVER, IT IS *NOT* A NECESSITY, SO DON'T WORRY ABOUT IT! :)
[Note: My modifications are also public domain. Ken wrote much of the
following, but I have changed a lot of it to match version 2.00. - J.L.
Hayes]
Now enough of this screaming!
1. CONV2SND is a program with one thing in mind: To open the worlds
of digitized sounds created on other machines and by other methods
to anyone using a Tandy 1000 SL, TL, RL, RLX, 2500 RLX, RSX and
every other machine that uses:
SOUND.PDM
Ken wrote: "I wish that Tandy had created something a few years ago
that would have done this, as it might have kept the Tandy's with the
superb 8-bit DAC a little more in step with the SoundBlaster, the
Macintosh, the Amiga and the Atari ST, all of which are able to create
superb digitized sounds and have programs that allow you to share them
with one another.
"So, here it is."
2. To start the program, type:
CONV2SND <infile>
or:
CONV2SND <infile> <outfile>
The process will then take place automatically. Filenames can include
drive and path if you want. If you use the first form, the output
filename will be the same as the input filename, including drive and
path if present, but with an ".snd" extension attached. If you use the
second form, the output filename will be what you specified. If the
output filename does not have an extension, it defaults to ".snd".
There is no default for the input file, so you have to specify the
extension for it. If you want the output file not to have an
extension, end its name with a period.
As of version 2.00, CONV2SND can read and understand .wav headers. The
.wav will be detected by the header, not by the filename. CONV2SND
will check that the .wav is an 8-bit mono file and display some advice
if it isn't (see below). If the .wav is 8-bit mono, CONV2SND will read
the sampling rate from the header and check to see if it is within 5%
of one of the three rates supported by Sound.pdm. If so, the sampling
rate will be taken from the .wav header, and you won't be asked about
that. If not, you will be told to resample the file. There is a
program available to do this, discussed below. If the .wav header is
invalid, you will be given the option of continuing as if the file were
not a .wav. I don't know how useful that will be.
You will be asked a couple of questions.
A) Asks about the sampling rate (speed of playback). You won't be
asked this question if CONV2SND is able to determine the sampling
rate from the .wav header.
These are the options (Ken's notes):
5500 is a slow sampling rate, often used for speech purposes or some
games. [5500 seems to be rare nowadays. - JLH]
11000 is the the most common sampling rate. It is #2 on the
selection list and the one you will want to try first. The
only reason it is so popular is that it is of sufficient
quality for music and such. 5500 really isn't. WAV files are
usually sampled at 11000 samples per second.
22000 is most often used with the Macintosh Sound files. It is of a
higher quality, but it does take up more disk space, which is
why it is the 2nd most popular sampling rate to record at.
[This rate is becoming more common. - JLH]
If you screw up and select the wrong one, that's okay! Just redo the
procedure and select a different rate next time!
[It should be mentioned that 44000, or 44kHz, is an increasingly
common rate. This is the rate that audio CD's are sampled at. The
Tandy sound chip is perfectly capable of going that fast, but
Sound.pdm does not support that speed. I have written a .wav player
for the Tandy chip that will play .wav's at 44kHz - see Snd2wav.doc.
Included here with CONV2SND is a utility called Ppwav that can cut
the sampling rate of these .wav's down to 22kHz so that CONV2SND can
convert them. See below. - JLH]
B) Asks for the "name" of the sound.
This isn't the file name. This is the name that appears when you
are in SOUND.PDM, right next to "Name: ", in the right hand box. If
you don't specify a name, none will be used. This is a change from
version 1.98, which required you to enter a name. It is a good idea
to specify a name anyway, in case the name of the file gets changed
at some point in the future.
You can read the name of the sound by typing DEBUG filename.snd and
then "d". You will see the name of the sound file in the right hand
side of the screen. (NOTE: "q" gets you out of DEBUG)
C) Asks for your name. "No real reason yet, but I'm thinking of one!"
writes Ken. Version 1.98 required you to enter your name; this
version will call you "CONV2SND user" if you don't enter a name.
A new file with your sound will be created. This is the DeskMate SOUND
version of the other digitized file.
3. You will need to do the following after the file is created:
* Go into SOUND.PDM, and load the new .SND file (F2, Open)
* Play the file and see if the conversion was done right. If the file
sounds like Alvin the Chipmunk, the sampling rate you gave was too
low; go back and run CONV2SND again with a higher rate. If it sounds
like Lurch on "The Addams Family," the rate is too high, and you need
to try a lower one. (That is, unless the file *is* a recording of
Lurch! :-) If the file sounds like nothing at all, just static, it
may not be an 8-bit mono PCM file. You will have to use a program
called Sox to convert it to one before CONV2SND can use it; see
below.
If the input file was a .wav, you should not have this problem. If
the .wav is of a type that can't be converted (most can), CONV2SND
will tell you why and halt without creating an output file.
* If the sampling rate seems right, carefully remove any noise at the
beginning of the file, using a very small increment (use "sample").
Beginning noise, if present, represents the header of the original
sound file; it is not actual sound. There are a few types of sound
files that don't have a header ("raw" files made by Sox are one - see
below), but most do. The noise will be a short click or pop.
Again, if the input file was a .wav, the .wav header will be deleted
automatically, and this problem will not arise.
* Hit F2 and Save the file.
Example: ROCKY.WAV is converted into ROCKY.SND
After listening to the file to check the conversion and getting
rid of the little beginning noise, hit F2, and Save. Exit
SOUND.PDM if you don't want to do more with the file at that time.
Here are some problems you may have, and what to do about them:
* If the file sounds like nothing at all, just static, it may not be an
8-bit unsigned mono PCM file. That means the sound data in the file
is not the right type for SOUND.PDM, and it will have to be converted
to 8-bit unsigned mono PCM before CONV2SND can use it. There is a
program called Sox that can tell you what kind of file it is and do
the conversion. As of this writing (6/22/1994), Sox is available by
ftp from:
oak.oakland.edu
Get file:
/pub/msdos/sounds/sox7dos.zip
and read the documentation that comes with Sox. You will need to
tell Sox to make its output file a RIFF WAVE file, size "byte," "1
channel" and select a sampling rate of 5500, 11000, or 22000. Use
the "verbose" option with the "stat" effect to find out what the
sampling rate of the original file is; if it's close to one of those
three, leave it alone. CONV2SND will accept sampling rates within 5%
of 5500, 11000, or 22000. It is best not to resample if you don't
have to since it introduces noise. Warning: Sox is a little
confusing to use at first.
As an alternative to Sox, this distribution includes a utility called
Ppwav that operates only on .wav files. Ppwav can convert wav's with
more than one channel to mono and larger sample sizes to 8-bit. It
can also cut the sampling rate of a file in half. Sox does all that
Ppwav does and more, but Ppwav is much faster and easier to use. If
you have a .wav that can't be converted because of one of the
problems that Ppwav can solve, CONV2SND will refuse to convert the
file and tell you to use Ppwav. See the separate documentation file
on Ppwav. Note that there are rare types of .wav's that neither Sox
nor Ppwav can convert.
* If you've tried all 3 sampling rates, 5500, 11000, and 22000, and
none of them seems to be right, you will have to resample the sound
to change the sampling rate to one of those three. SOUND.PDM can
only use one of those 3 rates. Sox (see above) can be used to do
this. Changing the sampling rate will introduce noise, unfortun-
ately; change to a sampling rate that is an integer multiple of the
original to minimize the noise.
Other sampling rates that I have seen are 8000, 15000, and 44000.
Sun .au files are usually sampled at 8000 (note that Sun .au is not
PCM but mu-law - Sox can convert these to .wav). If the input file
is a .wav, CONV2SND will refuse to convert the file if the header
indicates that the sampling rate is not one of the three that
Sound.pdm supports.
* If CONV2SND tells you the disk where the output file goes is full,
you will need to specify another drive for the output file, one with
more space on it. If you have a single-floppy system, you can
specify drive B:, and DOS will prompt you to swap disks when needed.
It will be awkward to do it this way, but it will work.
* If Sound.pdm tells you the .snd file won't fit in memory, there is
unfortunately not much you can do. If your system can take
additional DOS memory, you can install additional memory if you
haven't already. This is a very cheap upgrade and highly
recommended; check your owner's manual to find out how. I'm
referring to systems with less than 640k of DOS memory; I doubt that
Sound.pdm will use expanded or extended.
That's it! Ken's phone (908) 241-6246 is open for your use up 'till about
11pm or so. He is kudut@ritz.mordor.com on the Internet, and Kenneth Udut,
170 East Clay Avenue, Roselle Park, NJ USA 07204-2050.
Note: Ken hasn't worked with this program in a while, but I expect he will
continue to act as a clearinghouse for the various modifiers, such as
myself. I am responsible for the modifications from version 1.98 to
version 2.00, including much of the above text. My phone is (207) 866-
7903. I'm tvdog@delphi.com on the Internet. Snailmail: Jeffrey L. Hayes,
130 Forest Ave., Lot 1, Orono, Maine 04473.
"Thanks for reading and hope you NOT ONLY enjoy using it, but also play
around with the source code and work with it!
"I want to see a world where source code is freely distributable, where
there isn't all that "data-hiding" and all that. I would hate to see a
society where the 'elite programmers' only knew the secrets of 'real'
programming, while the peons were kept down low...
"I prefer openness and honesty, personally :)
"Talk to you soon!
"--Ken
"February 3, 1993"
FIDONET: Kenneth Udut @ 1:107/900
INTERNET: kudut@ritz.mordor.com
America Online: K Udut
PC-Link: K Udut
CompuServe: INTERNET> kudut@ritz.mordor.com
BITNET: kudut%ritz.mordor.com@yalevm.bitnet
Home Address:
Kenneth Udut
170 East Clay Avenue
Roselle Park, New Jersey 07204-2050
Phone Numbers:
(908) 241-6246
(908) 241-8528 -- FAX number
Can be found on:
The Juice Bar BBS, located in Roselle Park, New Jersey, USA
(908) 298-0764. I'm user #11, and a VERY VERY active poster!
I also run a list on BITNET.
Y-RIGHTS@SJUVM.BITNET - discussion on the rights of kids and teens.
"Leave me a message somewhere or give me a phone call! I'll set a pot of
tea out for you and we'll chat :)" - Ken
Also check out the Tandy sound package, now on Simtel! Play mono or stereo
8- or 16-bit .wav's of arbitrary size at up to 65535 Hz, record .wav's of
arbitrary length at up to 62kHz, convert raw 8-bit sound files to .wav,
convert 16-bit or stereo .wav's to mono 8-bit, convert .snd instrument
files to Amiga .mod samples (including looped samples!), use your Tandy DAC
with programs that support a generic DAC, and play your Tandy like a piano
with the 3-voice chip (chords too!). All source code included, and the
best, most complete programming information on the Tandy sound that you
will find anywhere! All free! How do I get this marvellous package, you
ask? Just ftp it from:
oak.oakland.edu:/pub/msdos/sound/tspak.zip
- JLH
-----------[technical stuff]------------
Many (but not all) types of sound files are basically identical to DeskMate
.snd. That is, the actual sound data is encoded in exactly the same way.
The difference lies in the "header."
The header of a file is a small series of bytes, usually 44 in the case of
DeskMate .snd files. The purpose of a header?
A header tells the program how big the file is, as most programs that read
digitized sound files need to be specially told how many bits of sound they
need to load up. It also might tell you the "name" or description of the
sound file. The sampling rate (how fast the sound was recorded and should
be played back) is also usually included.
Christopher Taveres was the first to try to decode the .snd header.
Chris's effort appeared as part of his SOUNDOFF.C program in _PCM_, the
Tandy magazine. Here's what he came up with:
======================================================================
/* Sound Off!
/* Written by Christopher Taveres
/* Copyright (c) January 1992
/* Falsoft, Inc.
/* PCM
/** Definintion for the header block for Deskmate .snd files **/
struct dmheader { /* Structure of the header block */
int marker; /* Marker bytes - should be 00 1a */
char note_count; /* Number of notes in instrument file */
char inst_num; /* Instrument number */
char inst_name[10]; /* Instrument name */
int sample_rate; /* Sampling rate */
char filler[16]; /* I don't know what this does */
unsigned long sample_size; /* Number of samples in file */
char filler2[8]; /* More unknown space */
======================================================================
Ken noticed that the marker bytes could be 1A 01 instead of 1A 00. The
number of samples confused him, however. After fiddling around with
Sound.pdm for a while, I filled in most of the blanks as follows:
TANDY DESKMATE .SND FORMAT NOTES
There are two types of DeskMate .snd files, sound files and instrument files.
Both contain 8-bit unsigned PCM samples. "PCM" stands for "pulse code
modulation" and just means that the sound wave is measured at fixed intervals
and its level recorded. It's just like you used to do in high school algebra
when you were asked to graph a function by evaluating it at various points.
With PCM, the samples are integers in a certain range; the Tandy sound chip
uses 0-255.
Sound files are simpler. These are garden-variety sample files with a fixed-
length header giving the name of the sound, the recording frequency, and the
length of the sound. Sound files may be recorded at 5500Hz, 11kHz or 22kHz.
Instrument files contain samples as well as frequency and looping information
used by Music.pdm to represent an instrument. Instrument files provide for
attack, sustain, and decay with several samples having different implied
frequencies and being used by Music.pdm to represent the instrument in
different pitch ranges. Up to 16 different notes (with 16 different samples)
can be contained in one instrument file. Instrument files are always recorded
at 11kHz.
Both sound files and instrument files may be compressed in one of two ways,
"music" compression or "speech" compression, or they may be uncompressed. I
don't know the compression algorithms, but simple file comparison reveals that
"music" and "speech" compression are almost identical.
The DeskMate .snd file header consists of 16 bytes of fixed header information
followed by one or more 28-byte note records. The sample information, which
may be compressed, follows the header.
The information below is the old-format .snd header used by the 1000-series.
This is the format written by CONV2SND. The 2500's use a somewhat different
header when writing (see Snd2wav.doc), but they can read the old format.
DeskMate .snd File Format - Fixed Header
----------------------------------------
offset size what
------ ---- ----
0 byte 1Ah (.snd ID byte). Note that 1Ah = <cntrl>-Z, so if
a user attempts to type the .snd file to the screen,
nothing will be displayed.
1 byte Compression code: 0 = no compression; 1 = music
compression; 2 = speech compression.
2 byte Number of notes in the instrument file. 1 if sound
file. There can be up to 16 notes in an instrument
file. Note: when an instrument file is created, it
automatically has one unset note placed in it.
3 byte Instrument number. 0 if sound file; 0FFh if instrument
file with no number set. Valid instrument numbers in
an instrument file are 1 to 32. Use this field to
distinguish a sound file from an instrument file.
4 10 bytes Sound or instrument name. Name is a null-terminated
string, so there are up to 9 characters of the name,
plus the null byte.
0Eh word Sampling rate in samples per second. Note that although
a sampling rate other than 5500, 11000 and 22000 can be
entered here, Sound.pdm will not actually play at other
rates.
10h variable Note records begin, 28 bytes each. Number of records
given in byte 2 above.
DeskMate .snd File Format - Note Record
---------------------------------------
0 byte Pitch of the note: 1 = A1 in American Standard Pitch;
2 = A#1; etc. A1 is lowest note allowed; highest note
allowed is B6 (3Fh). Sound files have 0FFh here; so do
instrument files with no note set.
Note that Sound.pdm does not designate notes in the
standard manner to the user. Although A1 and B6 in
Sound.pdm are the same as A1 and B6 in standard pitch,
Sound.pdm starts octaves at A rather than at C (as is
standard). Thus, middle C, C4 in standard pitch, is C3
in Sound.pdm.
1 byte Sound files, and instrument files with no pitch set,
have 0 here. If the pitch is set, this byte is 0FFh.
2 2 bytes Range of the note, first byte is lower limit, second
is higher limit. Byte encoding as for offset 0 (i.e.,
01h to 3Fh). Sound files have FF FF here; so do
instrument files with no range set.
4 dword Offset in the file where samples for this note begin
(zero-relative), after compression if that was done.
8 dword If compressed, the length of the compressed data in the
file for this note. Uncompressed files have 0 here.
0Ch 4 bytes Unknown. Set to zero.
10h dword Number of samples in the note, after decompression if
necessary. 0 can appear here, meaning the note is not
set, or the sound file is empty.
14h dword Number of sample at start of sustain region for the
note, relative to the first (zeroth) sample of the note.
For sound files, or if sustain is not set, this field is
0.
18h dword Number of sample at end of sustain region for the note,
relative to the first (zeroth) sample of the note. For
sound files, or if sustain is not set, this field is 0.
//// end of conv2snd.doc ////